<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<fmt:message var="title" key="employee.list.title"/>
<my:layout title="${title}">
 <jsp:attribute name="body">

        <p><fmt:message key="employee.list.allemployees"/></p>

        <table class="basic">
            <tr>
                <th>id</th>
                <th><fmt:message key="user.login"/></th>
                <th><fmt:message key="user.name"/></th>
                <th><fmt:message key="user.surname"/></th>
                <th><fmt:message key="user.email"/></th>
                <th><fmt:message key="user.phone"/></th>
                <th></th>
                <th></th>
                <th></th>
            </tr>
            <c:forEach items="${employees}" var="employee">
                <tr>
                    <td>${employee.id}</td>
                    <td><c:out value="${employee.login}"/></td>
                    <td><c:out value="${employee.contact.name}"/></td>
                    <td><c:out value="${employee.contact.surname}"/></td>
                    <td><c:out value="${employee.contact.email}"/></td>
                    <td><c:out value="${employee.contact.phone}"/></td>
                   
                    <td>
                        <form method="post" action="${pageContext.request.contextPath}/employee/delete/${employee.id}">
                            <input type="submit" value="<fmt:message key='user.list.delete'/>">
                        </form>
                    </td> 
                    
                                        <td>
                        <form method="get" action="${pageContext.request.contextPath}/employee/update/${employee.id}">
                            <input type="submit" value="<fmt:message key='employee.update'/>">
                        </form>
                    </td>
                     <td>
                        <form method="get" action="${pageContext.request.contextPath}/account/update/${employee.login}">
                            <input type="submit" value="<fmt:message key='account.account'/>">
                        </form>
                    </td>
                </tr>
            </c:forEach>
        </table>
  <form:form method="post" action="${pageContext.request.contextPath}/employee/update" modelAttribute="employee">
    <fieldset><legend><fmt:message key="employee.list.titleNew"/></legend>
    <%@include file="form.jsp"%>
    <input type="submit" value="<fmt:message key='employee.list.createemployee'/>">
    </fieldset>
</form:form>
</jsp:attribute>
</my:layout>